home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1989 / 02 / pmdev2 / spmtplnt.c < prev    next >
Text File  |  1988-10-18  |  2KB  |  73 lines

  1. #define INCL_PM
  2. #include <os2.h>
  3. #include <stddef.h>
  4. #include "spmtpl.h"
  5.  
  6. BOOL FAR InitProgram(int argc, char *argv[])
  7. {
  8.  
  9.     char szTitle[50];
  10.     ULONG ctldata;
  11.  
  12.   /* get anchor block handle and message queue handles */
  13.     if ((hAB = WinInitialize(NULL)) == NULL)
  14.     return FALSE;
  15.  
  16.     if ((hmqMsgQ = WinCreateMsgQueue(hAB,0)) == NULL)
  17.         return FALSE;
  18.  
  19.   /* This string is needed to register the Window */
  20.     WinLoadString(hAB,NULL, IDS_APPNAME, sizeof(szAppName), (PSZ)szAppName);
  21.  
  22.     if (!WinRegisterClass(hAB,             /* anchor block handle */
  23.               (PCH)szAppName,     /* class name */
  24.               (PFNWP)MainWndProc,    /* window procedure for class */
  25.               CS_SIZEREDRAW,       /* class styles */
  26.               0))            /* no extra data needed */
  27.     return FALSE;
  28.  
  29.   /* This string is needed to create the frame window */
  30.     WinLoadString(hAB, NULL, IDS_TITLE, sizeof(szTitle), (PSZ)szTitle);
  31.  
  32.     ctldata = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX;
  33.  
  34.     hwndFrame = WinCreateStdWindow(HWND_DESKTOP,    /* parent */
  35.                    WS_VISIBLE,
  36.                    &ctldata,
  37.                                    (PCH)szAppName,    /* class */
  38.                                    (PCH)szTitle,    /* window title */
  39.                                    0L,            /*default client style*/
  40.                                    (HMODULE)NULL,    /* resources in .EXE */
  41.                                    NULL,        /* frame id */
  42.                                    (HWND FAR *)&hwndMain);
  43.                             /* handle to client */
  44.  
  45.     if (hwndFrame) {
  46.         WinShowWindow(hwndFrame, TRUE);
  47.     return TRUE;
  48.     }
  49.     return FALSE;
  50. }
  51.  
  52. /* called when client is created */
  53. void FAR WndCreate(HWND hWnd)
  54. {
  55.  
  56.     FONTMETRICS FM;
  57.     HPS hPS;
  58.  
  59.   /* get the size of an icon */
  60.     xIconsize = WinQuerySysValue(HWND_DESKTOP, SV_CXICON);
  61.     yIconsize = WinQuerySysValue(HWND_DESKTOP, SV_CYICON);
  62.  
  63.   /* load the icon string */
  64.     WinLoadString(hAB, NULL, IDS_ICON, (USHORT)sizeof(szIcon), (PSZ)szIcon);
  65.  
  66.   /* get the system font character metrics */
  67.     hPS = WinGetPS(hWnd);
  68.     GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &FM);
  69.     CharHeight = FM.lMaxBaselineExt + FM.lExternalLeading;
  70.     CharWidth = FM.lAveCharWidth;
  71.     WinReleasePS (hPS);
  72. }
  73.